package invoicesystem.service.impl;

import invoicesystem.dao.EmailDao;
import invoicesystem.dao.impl.EmailDaoImpl;
import invoicesystem.entry.Address;
import invoicesystem.entry.Email;
import invoicesystem.service.EmailService;

import java.util.ArrayList;

public class EmailServiceImpl implements EmailService {
    EmailDao emailDao=new EmailDaoImpl();
    @Override
    public int insertEmail(Email email) {
        return emailDao.insertEmail(email);
    }

    @Override
    public int updateEmail(Email email) {
        return  emailDao.updateEmail(email);
    }

    @Override
    public Email selectDefalut(Integer enterprise_id) {
        ArrayList<Email> list= emailDao.select(enterprise_id);
        ArrayList<Email> list1=new ArrayList<>();
        for ( Email e:list
             ) {
            if (e.getDefault_status().equals("默认")){
                list1.add(e);
            }
        }
        return list1.get(0);
    }

    @Override
    public ArrayList<Email> select(Email email) {
        return emailDao.select(email.getEnterprise_id());
    }

    @Override
    public ArrayList<Email> selectAll() {
        return emailDao.selectAll();
    }

    @Override
    public int updateStatus(Email email) {
        return emailDao.updateStatus(email);
    }
    @Override
    public Email selectByEmail_detail(String email_detail) {
        return emailDao.selectByEmail_detail(email_detail);
    }

    @Override
    public ArrayList<Email> selectById(int enterprise_id) {
        return emailDao.selectById(enterprise_id);
    }

    @Override
    public ArrayList<Email> selectAll(int id) {
        return emailDao.selectAll(id);
    }

    @Override
    public Email selectDefault(Integer enterprise_id) {
        return emailDao.selectDefault(enterprise_id);
    }

}
